58fc208c2c3c75ad516f00f089c4cba0be1fe0f2
[pcl.git] /
1 /*
2  * Software License Agreement  (BSD License)
3  *
4  *  Point Cloud Library  (PCL) - www.pointclouds.org
5  *  Copyright  (c) 2012, Jeremie Papon.
6  *
7  *  All rights reserved.
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *
13  *   * Redistributions of source code must retain the above copyright
14  *     notice, this list of conditions and the following disclaimer.
15  *   * Redistributions in binary form must reproduce the above
16  *     copyright notice, this list of conditions and the following
17  *     disclaimer in the documentation and/or other materials provided
18  *     with the distribution.
19  *   * Neither the name of Willow Garage, Inc. nor the names of its
20  *     contributors may be used to endorse or promote products derived
21  *     from this software without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  (INCLUDING,
29  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  *  LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  *  POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37
38 #include <pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h>
39
40 namespace pcl
41 {
42   namespace cloud_composer
43   {
44       
45     class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor
46     {     
47       public:
48         static SelectedTrackballStyleInteractor* New();
49         vtkTypeMacro(SelectedTrackballStyleInteractor,vtkInteractorStyleTrackballActor);
50         
51         SelectedTrackballStyleInteractor ();
52         
53         ~SelectedTrackballStyleInteractor ();
54                
55         /** \brief Pass a pointer to the actor map
56           * \param[in] actors the actor map that will be used with this style
57           */
58         inline void 
59         setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; }
60
61         /** \brief Get the cloud actor map pointer. */
62         inline pcl::visualization::CloudActorMapPtr 
63         getCloudActorMap () const { return (actors_); }
64
65         /** \brief Pass a set of renderers to the interactor style. 
66           * \param[in] rens the vtkRendererCollection to use
67           */
68         void 
69         setRendererCollection (vtkSmartPointer<vtkRendererCollection> &rens) { renderers_ = rens; }
70
71         /** \brief Function called on left mouse button click, ie, beginning of trackball */
72         void
73         OnLeftButtonDown () override;
74         
75         void
76         OnRightButtonDown () override;
77         
78         /** \brief Function called on left mouse button release, ie, end of trackball*/
79         void
80         OnLeftButtonUp () override;
81         
82         void
83         OnRightButtonUp () override;
84
85         void 
86         Rotate() override;
87         void 
88         Spin() override;
89         void 
90         Pan() override;
91         void 
92         UniformScale() override;
93         
94         /** \brief Event emitted once a valid selection has been made */
95         int manipulation_complete_event_;
96         
97         inline void 
98         setProjectModel (ProjectModel* model) { model_ = model; }
99       private:
100
101         void
102         setSelectedActors ();
103         
104         /** \brief Actor map stored internally. */
105         pcl::visualization::CloudActorMapPtr actors_;
106         
107         /** \brief Collection of vtkRenderers stored internally. */
108         vtkSmartPointer<vtkRendererCollection> renderers_;
109         
110         /** \brief Internal Pointer to Project Model */
111         ProjectModel* model_;
112         
113         QMap <QString, vtkSmartPointer<vtkMatrix4x4> > start_matrix_map_;
114         QMap <QString, vtkLODActor*> selected_actors_map_;
115         
116     };
117     
118   }
119   
120 }